home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / misc / robots.lha / player / schwan.r < prev    next >
Text File  |  1993-04-26  |  2KB  |  107 lines

  1. Gio's home & Users
  2. Andre,Gio,Peter
  3. /* 'sterbender Schwan'
  4.    der Ästhet unter den Robots - er tänzelt über das
  5.    Spielfeld und zermantscht dabei seine Gegner */
  6.  
  7. main() {
  8.  int px, py;
  9.  int stepwidth;
  10.  int r, alpha;
  11.  int direction;
  12.  int range;
  13.  int olddam;
  14.  int tmp;
  15.  int i;
  16.  
  17.  stepwidth=10;
  18.  drive(0,0);
  19.  
  20.  r=distance(loc_x(),loc_y(),500,500);
  21.  alpha=degree(loc_x(),loc_y(),500,500);
  22.  while (r>499) {
  23.   alpha=degree(loc_x(),loc_y(),500,500);
  24.   drive(alpha,49);
  25.   r=distance(loc_x(),loc_y(),500,500);
  26.  }
  27.  drive(0,0);
  28.  alpha=180+alpha;
  29.  
  30.  while (1) {
  31.   olddam=damage();
  32.   alpha=alpha+stepwidth;
  33.   px=500+(r*cos(alpha))/100000;
  34.   py=500+(r*sin(alpha))/100000;
  35.   direction=degree(loc_x(),loc_y(),px,py);
  36.   drive(direction,50);
  37.   while (distance(loc_x(),loc_y(),px,py)<10) {
  38.   }
  39.   tmp=shoot(direction);
  40.   if (rand(10)==1) {
  41.    r=r+(rand(200)-100);
  42.    if (r>450) r=450;
  43.    if (r<100) r=100;
  44.   }
  45.   if (olddam!=damage())
  46.    if (stepwidth<90) stepwidth+=20;
  47.   else
  48.    if (stepwidth>13) stepwidth--;
  49.  }
  50. }
  51.  
  52. /* Den Winkel der Verbindungsstrecker zweier Punkte am 2. Punkt
  53.    ausrechnen */
  54.  
  55. int degree(x1,y1,x2,y2)
  56. {
  57.  int dx,dy;
  58.  dx=(x2-x1);
  59.  dy=(y2-y1);
  60.  if (dx>0)
  61.  {
  62.   if (dy>0)
  63.   {
  64.    return (atan((100000*dy)/dx));         /* 1. Quadrant */
  65.   } else if (dy==0) {
  66.    return (0);
  67.   } else {
  68.    return (360-atan((100000*-dy)/dx));    /* 4. Quadrant */
  69.   }
  70.  } else {
  71.   if (dy>0)
  72.   {
  73.    return (180-atan((100000*dy)/-dx));    /*  2. Quadrant */
  74.   } else if (dy==0) {
  75.    return (180);
  76.   } else {
  77.    return (180+atan((100000*-dy)/-dx));   /* 3. Quadrant */
  78.   }
  79.  }
  80. }
  81.  
  82. int distance(x1,y1,x2,y2)
  83. {
  84.  return(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
  85. }
  86.  
  87. int shoot(direction)
  88. {
  89.  int i;
  90.  int range;
  91.  
  92. /* ZZA:
  93.    Hier stand eine auskommentierte Befehlsgruppe, die Gio mich
  94.    händeringend zu entfernen bat. Da sie auf dem Netz nur Platz
  95.    verschwendet, tat ich ihm den Gefallen. Das Original findet
  96.    sich selbstverständlich noch auf meiner Platte 8-)
  97. */
  98.  i=-180;
  99.  while ((i+=20)<180) {
  100.   if ((range=scan(direction+i,10))>0) {
  101.    cannon(direction+i,range);
  102.    i=180;
  103.   }
  104.  }
  105.  return(0);
  106. }
  107.